/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sn.gandal.mobile.kalpet.persistence;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * @version V 1.0 01/03/2010
 * @author SOWDIOMYERO
 */
@Entity
@Table(name = "credentials", catalog = "kmobile", schema = "", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"idaccount"}),
    @UniqueConstraint(columnNames = {"identifier"})})
@NamedQueries({
    @NamedQuery(name = "Credentials.findAll", query = "SELECT c FROM Credentials c"),
    @NamedQuery(name = "Credentials.findById", query = "SELECT c FROM Credentials c WHERE c.id = :id"),
    @NamedQuery(name = "Credentials.findByUsername", query = "SELECT c FROM Credentials c WHERE c.username = :username"),
    @NamedQuery(name = "Credentials.findByPassword", query = "SELECT c FROM Credentials c WHERE c.password = :password"),
    @NamedQuery(name = "Credentials.findByVerifcode", query = "SELECT c FROM Credentials c WHERE c.verifcode = :verifcode"),
    @NamedQuery(name = "Credentials.findByEnabled", query = "SELECT c FROM Credentials c WHERE c.enabled = :enabled"),
    @NamedQuery(name = "Credentials.findByFacebookid", query = "SELECT c FROM Credentials c WHERE c.facebookid = :facebookid"),
    @NamedQuery(name = "Credentials.findByTwitterid", query = "SELECT c FROM Credentials c WHERE c.twitterid = :twitterid"),
    @NamedQuery(name = "Credentials.findByEmailaddress", query = "SELECT c FROM Credentials c WHERE c.emailaddress = :emailaddress"),
    @NamedQuery(name = "Credentials.findByIdphoto", query = "SELECT c FROM Credentials c WHERE c.idphoto = :idphoto"),
    @NamedQuery(name = "Credentials.findByExternephoto", query = "SELECT c FROM Credentials c WHERE c.externephoto = :externephoto"),
    @NamedQuery(name = "Credentials.findByMobile", query = "SELECT c FROM Credentials c WHERE c.mobile = :mobile"),
    @NamedQuery(name = "Credentials.findByIdentifier", query = "SELECT c FROM Credentials c WHERE c.identifier = :identifier")})
public class Credentials implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "username", nullable = false, length = 20)
    private String username;
    @Basic(optional = false)
    @Column(name = "password", nullable = false, length = 50)
    private String password;
    @Column(name = "verifcode", length = 20)
    private String verifcode;
    @Basic(optional = false)
    @Column(name = "enabled", nullable = false)
    private short enabled;
    @Column(name = "facebookid", length = 255)
    private String facebookid;
    @Column(name = "twitterid", length = 255)
    private String twitterid;
    @Basic(optional = false)
    @Column(name = "emailaddress", nullable = false, length = 255)
    private String emailaddress;
    @Column(name = "idphoto")
    private Integer idphoto;
    @Column(name = "externephoto", length = 50)
    private String externephoto;
    @Lob
    @Column(name = "bio", length = 65535)
    private String bio;
    @Basic(optional = false)
    @Column(name = "mobile", nullable = false, length = 32)
    private String mobile;
    @Column(name = "identifier", length = 250)
    private String identifier;
    @JoinColumn(name = "idaccount", referencedColumnName = "id", nullable = false)
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private Account account;

    public Credentials() {
    }

    public Credentials(Integer id) {
        this.id = id;
    }

    public Credentials(Integer id, String username, String password, short enabled, String emailaddress, String mobile) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.enabled = enabled;
        this.emailaddress = emailaddress;
        this.mobile = mobile;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getVerifcode() {
        return verifcode;
    }

    public void setVerifcode(String verifcode) {
        this.verifcode = verifcode;
    }

    public short getEnabled() {
        return enabled;
    }

    public void setEnabled(short enabled) {
        this.enabled = enabled;
    }

    public String getFacebookid() {
        return facebookid;
    }

    public void setFacebookid(String facebookid) {
        this.facebookid = facebookid;
    }

    public String getTwitterid() {
        return twitterid;
    }

    public void setTwitterid(String twitterid) {
        this.twitterid = twitterid;
    }

    public String getEmailaddress() {
        return emailaddress;
    }

    public void setEmailaddress(String emailaddress) {
        this.emailaddress = emailaddress;
    }

    public Integer getIdphoto() {
        return idphoto;
    }

    public void setIdphoto(Integer idphoto) {
        this.idphoto = idphoto;
    }

    public String getExternephoto() {
        return externephoto;
    }

    public void setExternephoto(String externephoto) {
        this.externephoto = externephoto;
    }

    public String getBio() {
        return bio;
    }

    public void setBio(String bio) {
        this.bio = bio;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Credentials)) {
            return false;
        }
        Credentials other = (Credentials) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sn.gandal.mobile.kalpet.persistence.Credentials[id=" + id + "]";
    }

}
